package com.sqj.singletonPattern.enums;

import java.io.*;

public class EnumSingletonTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        EnumSingleton e1=null;
        EnumSingleton e2=EnumSingleton.getInstance();
        e2.setData(new Object());
        FileOutputStream fos = new FileOutputStream("EnumSingelton.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(e2);
        oos.flush();
        oos.close();

        FileInputStream fis = new FileInputStream("EnumSingelton.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        e1= (EnumSingleton) ois.readObject();
        System.out.println(e1.getData());
        System.out.println(e2.getData());
        System.out.println(e1.getData()==e2.getData());
    }
}
